package com.wxapp.custom.service.controller.client;

import com.wxapp.common.constant.base.IBaseController;
import com.wxapp.common.constant.pojo.vm.ResultVm;
import com.wxapp.common.constant.pojo.vo.UserVo;
import com.wxapp.common.core.annotation.User;
import com.wxapp.custom.api.pojo.vm.customAccount.PCustomAccountDetailVm;
import com.wxapp.custom.api.pojo.vo.customAccount.QCustomAccountAddVo;
import com.wxapp.custom.api.pojo.vo.customAccount.QCustomAccountUpdateVo;
import com.wxapp.custom.service.service.AccountService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * @author lgl
 * @Description 用户账户
 * @Datetime 2022/7/4 15:52
 * @Modified By
 */
@RequestMapping("/client/account")
@Tag(name = "用户账户")
@RestController
@RequiredArgsConstructor
public class AccountClientController extends IBaseController {
   private final AccountService userAccountService;

    @GetMapping("/getAccount")
    @Operation(summary ="得到账户详情")
    public ResultVm<PCustomAccountDetailVm> getAccount(@Schema(hidden = true) @User UserVo userVo) {
        return userAccountService.getAccount(userVo);
    }

    @PutMapping("update")
    @Operation(summary ="更新用户账户")
    public ResultVm<String> update(@RequestBody QCustomAccountUpdateVo qCustomAccountUpdateVo, @Schema(hidden = true) @User UserVo userVo) {
        return userAccountService.update(qCustomAccountUpdateVo, userVo);
    }

    @PostMapping("save")
    @Operation(summary ="新建账户")
    public ResultVm<String> save(@Schema(hidden = true) @User UserVo userVo, @RequestBody QCustomAccountAddVo qCustomAccountAddVo) {
        return userAccountService.save(userVo, qCustomAccountAddVo);
    }
}
